<%@ page import="Task_0106.Dao" %><%--
  Created by IntelliJ IDEA.
  User: 青春掌舵手
  Date: 2021/8/12
  Time: 15:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
  <head>
    <title>后端验证</title>
  </head>
  <body>
    <%
      //处理post请求的乱码
      request.setCharacterEncoding("utf-8");
      //接收前端数据
      String userName = request.getParameter("userName");
      String password = request.getParameter("password");
      session.setAttribute("userName", userName);

      //判断密码是否正确 并跳转页面
      Dao d = new Dao();
      boolean result = d.login(userName, password);
      if(result==true){
        response.sendRedirect("/success.jsp");
      }else {
        out.print("<script>alert('用户名或密码错误')</script>");
      }
    %>
  </body>
</html>
